package com.asset.troubleticket.dao;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.asset.troubleticket.domain.JobTitle;
@Repository
public class JobTitleDao {
	@Autowired
	SessionFactory sessionFactory;
	
	
	public void addJobTitle(JobTitle jobtitle){
		try{
			sessionFactory.getCurrentSession().save(jobtitle);
			}catch(Exception ex){
				ex.printStackTrace();
			}
	}
	
	
	public void editJobTitle(JobTitle jobtitle){
		try{
			sessionFactory.getCurrentSession().saveOrUpdate(jobtitle);
			}catch(Exception ex){
				ex.printStackTrace();
			}
	}
	
	public void deleteJobTitle(JobTitle jobtitle){
		try{
			sessionFactory.getCurrentSession().delete(jobtitle);
			}catch(Exception ex){
				ex.printStackTrace();
			}
	}
	
	public JobTitle getById(Integer id){
		try{
		return (JobTitle)	sessionFactory.getCurrentSession().load(JobTitle.class,id);
			}catch(Exception ex){
				ex.printStackTrace();
				return null;
			}
	}
}
